# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=gsad
pkgver=22.9.1
pkgrel=0
pkgdesc="Greenbone Security Assistant HTTP Server - The server talking to the Greenbone Vulnerability Management (GVM) deamon"
url="https://www.openvas.org/"
arch="all !riscv64" # limited by gsa
license="AGPL-3.0-or-later"
pkgusers="gvm"
pkggroups="gvm"
depends="gsa"
makedepends="
	cmake
	doxygen
	glib-dev
	graphviz
	gvm-libs-dev
	libgcrypt-dev
	libmicrohttpd-dev
	libxml2-dev
	libxslt-dev
	py3-polib
	samurai
	xmltoman
	"
checkdepends="cppcheck"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/gsad/archive/refs/tags/v$pkgver.tar.gz
	fix-bin-path.patch
	$pkgname.initd
	$pkgname.logrotate"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSCONFDIR=/etc \
		-DGSAD_PID_PATH=/run/gsad/gsad.pid \
		-DGVMD_RUN_DIR=/run/gvmd \
		-DGSAD_RUN_DIR=/run/gsad \
		-DLOCALSTATEDIR=/var \
		-DLOGROTATE_DIR=/etc/logrotate.d

	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure -j${JOBS:-2}
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	rm -rf "$pkgdir"/lib/systemd
}

sha512sums="
25592b7e07357ff41f142cf926132491af20757a404773f3d532bafbf6e75d98b259103860920f657512d16a120351478767d347b01bef122ea1177c685d0d5b  gsad-22.9.1.tar.gz
2004f92b395695684ea827afbee7d5177980491ae516f449630a848c9145cbffeb882836860e3d70944f34699a38a3e6739f926073d81284e29b2cb2f4ad861b  fix-bin-path.patch
70db1ef2b79dba7e13dd8d24acd0432828387e313fce4e922873cb95a958e7071c4731d32abd63453c4a7b397ea7433a1c52c478a893f99e3c14304dccfd6042  gsad.initd
ae2e030a4e0a6cb3022706d64d65990ee8fafb36dbff2e76478e68748a2c1deca1679408ea029140f08e0d32cf8060475f9c763a263252cff80a86047101dab0  gsad.logrotate
"
